﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DefectSummary.BUS;
using DefectSummary.defectinterface;

namespace DefectSummary.bus.defect
{
    class DefectList : IDefectList
    {
        private List<Defect> defects = new List<Defect>();

        public int IndexOf(IDefect item)
        {
            return this.defects.IndexOf((Defect)item);
        }

        public void Insert(int index, IDefect item)
        {
            this.defects.Insert(index, (Defect)item);
        }

        public void RemoveAt(int index)
        {
            this.defects.RemoveAt(index);
        }

        public IDefect this[int index]
        {
            get
            {
                return this.defects[index];
            }
            set
            {
                this.defects[index] = (Defect)value;
            }
        }

        public void Add(IDefect item)
        {
            this.defects.Add((Defect)item);
        }

        public void Clear()
        {
            this.defects.Clear();
        }

        public bool Contains(IDefect item)
        {
            return this.defects.Contains(item);
        }

        public void CopyTo(IDefect[] array, int arrayIndex)
        {
            this.defects.CopyTo((Defect[])array, arrayIndex);
        }

        public int Count
        {
            get { return this.defects.Count; }
        }

        public bool IsReadOnly
        {
            get { return false; }
        }

        public bool Remove(IDefect item)
        {
            return this.Remove((Defect)item);
        }

        public IEnumerator<IDefect> GetEnumerator()
        {
            return this.defects.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
}
